const fs = require('fs');

console.log('开始异步读取文件！');
fs.readFile('./data.txt', 'utf8', (error, data) => {
  // 异步报错的处理
  if(error) {
    throw error
  }else {
    console.log(`异步content:${data}`);
  }
})
console.log('异步读取文件结束！');

// ===================11111333333

console.log('开始同步读取文件！')
try {
  let content = fs.readFileSync('./dat7777a.txt', 'utf8');
  console.log(`同步content:${content}`)
} catch (error) {
  console.log(error)
}
console.log('同步读取文件结束！')